package reflect;

import java.lang.reflect.InvocationTargetException;

import org.junit.Test;

/**
 * @author jiangwz
 * @create 2021/3/1.
 */
public class TestJdkReflect {

    private Integer age;

    @Override
    public String toString() {
        return "TestJdkReflect{" +
                "age=" + age +
                '}';
    }

    @Test
    public void testReflect() throws ClassNotFoundException, IllegalAccessException, InstantiationException, NoSuchMethodException, InvocationTargetException {
        Class<?> clazz = Class.forName("reflect.TestJdkReflect");
        Object o1 = clazz.getConstructor().newInstance();
        TestJdkReflect o = (TestJdkReflect) clazz.newInstance();
        o.age = 1;
        System.out.println(o);

    }


}
